// 类的只读属性

export {}; // 确保跟其它示例没有成员冲突

class Person {
    public name: string; // = 'init name'
    private age: number;
    // 只读成员
    protected readonly gender: boolean;

    constructor(name: string, age: number) {
        this.name = name;
        this.age = age;
        this.gender = true;
    }

    sayHi(msg: string): void {
        console.log(`I am ${this.name}, ${msg}`);
        console.log(this.age);
    }
}

const tom = new Person('tom', 18);
console.log(tom.name);
// tom.gender = false
